<template>
  <div class="figure">
    <van-nav-bar style="background-color: #DBECFE;" left-arrow title="人物" @click-left="emit('back')" />
    <div class="imgList">
      <div class="imgItem" v-for="item in fileList" :key="item" @click="selected(item)">
        <van-image round width="100" height="100" :src=item.url @click="emit('imgClick')" />
        <span class="title">{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps, onMounted } from "vue";

const emit = defineEmits(['back', 'imgClick'])
const { fileList } = defineProps(['fileList']);

const selected = (item) => {
  emit('imgClick', item)
}

onMounted(async () => {
  console.log(fileList)
})

</script>

<style lang="scss" scoped>
.figure {
  width: 100%;
  height: 100%;
  padding: 16px;
  background-color: #DBECFE;

  .imgList {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;

    .imgItem {
      position: relative;
      margin-bottom: 34px;
      width: 33%;
      display: flex;
      justify-content: center;

      .title {
        position: absolute;
        bottom: -20px;
        width: 100%;
        text-align: center;
        left: 50%;
        transform: translateX(-50%);
        font-size: 12px
      }
    }
  }
}
</style>
